package com.jxd.hbase.analysis;

import com.jxd.entity.MesHead;
import com.jxd.model.EventRecord;
import com.jxd.repositories.MesHeadRepositories;
import com.jxd.service.FaultTypeService;
import com.jxd.service.ProcessStaticService;
import com.jxd.service.impl.ProcessStaticServiceImpl;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.HTable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class ProcessStatic {
    @Value("${hbase.bwcontent.tablename}")
    private String bwContentTableName;
    @Autowired
     ProcessStaticServiceImpl processStaticService;
    @Autowired
    @Qualifier("getHtableByMesContent")
    HTable mesContentClient;
    @Autowired
    MesHeadRepositories mesHeadRepositories;
    public void  getProcessStatic(String shipid, String filename, String mesid , Connection connection){
        long st = new Date().getTime();
        //获取发射报文
        List<MesHead> launchMesHeads =processStaticService.getLaunchMesHead(filename, mesid, shipid);
        long launchMesHeadsst = new Date().getTime();
        System.out.println("launchMesHeadstime==="+(launchMesHeadsst-st));
        System.out.println("launchMesHeads=="+launchMesHeads.size());
        //获取发射记录
        List<EventRecord> launchRecords = processStaticService.getLaunchRecord(launchMesHeads);
        long launchRecordstime = new Date().getTime();
        System.out.println("launchRecordstime==="+(launchRecordstime-launchMesHeadsst));
        System.out.println("launchRecords=="+launchRecords.size());
        //写入数据库

     //   processStaticService.insertEventRecord(launchRecords);
        long insertEventRecordtime = new Date().getTime();
        System.out.println("insertEventRecordtime=="+(insertEventRecordtime-launchRecordstime));
        System.out.println("总时间=================="+(insertEventRecordtime-st));
    }
}
